package org.zjvis.graph.analysis.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.zjvis.graph.analysis.service.HealthyCheckService;
import org.zjvis.graph.analysis.service.exception.BaseErrorCode;
import org.zjvis.graph.analysis.service.exception.GraphAnalysisException;

@RequestMapping("/plugin")
@RestController
@Validated
public class PluginController {
    @Autowired
    private HealthyCheckService healthyCheckService;

    @GetMapping("/checkHealth")
    public String checkHealth() {
        boolean flag = healthyCheckService.check();
        if (flag) {
            return "success";
        } else {
            throw new GraphAnalysisException(BaseErrorCode.HEALTHY_CHECK_ERROR);
        }
    }
}
